package com.yuchao.base.xyc004.factory.abstractfactory;

import com.yuchao.base.xyc004.factory.simplefactory.ComputerService;

/**
 * Created by xingyuchao on 2017-06-17.
 * 测试抽象工厂
 */
public class Main {
    public static void main(String[] args) {

//        ComputerFactory computerFactory = new ComputerFactory() {
//            @Override
//            public ComputerService getComputer() {
//                return new AsusFactory().getComputer();
//            }
//        };
//        ComputerService ComputerService = computerFactory.getComputer();
//        System.out.println(ComputerService.getBrand());
//        ComputerService = computerFactory.getComputer("Dell");
//        System.out.println(ComputerService.getBrand());


        //Spring中的工厂模式也是这样，通过一个getBean 来获取一下各种bean
        DefaultAbstructFactory defaultAbstructFactory = new DefaultAbstructFactory();
        ComputerService computer = defaultAbstructFactory.getComputer();
        System.out.println(computer.getBrand());
        computer = defaultAbstructFactory.getComputer("ThinkPad");
        System.out.println(computer.getBrand());

    }
}